<!-- HTML header for doxygen 1.8.6-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/xhtml;charset=utf-8" http-equiv="Content-Type"/>
<meta content="IE=9" http-equiv="X-UA-Compatible"/>
<meta content="Doxygen 1.8.13" name="generator"/>
<title>OpenCV: Optimization Algorithms</title>
<link href="../../opencv.ico" rel="shortcut icon" type="image/x-icon"/>
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
<script src="../../jquery.js" type="text/javascript"></script>
<script src="../../dynsections.js" type="text/javascript"></script>
<script src="../../tutorial-utils.js" type="text/javascript"></script>
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
<script src="../../search/searchdata.js" type="text/javascript"></script>
<script src="../../search/search.js" type="text/javascript"></script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
//<![CDATA[
MathJax.Hub.Config(
{
  TeX: {
      Macros: {
          matTT: [ "\\[ \\left|\\begin{array}{ccc} #1 & #2 & #3\\\\ #4 & #5 & #6\\\\ #7 & #8 & #9 \\end{array}\\right| \\]", 9],
          fork: ["\\left\\{ \\begin{array}{l l} #1 & \\mbox{#2}\\\\ #3 & \\mbox{#4}\\\\ \\end{array} \\right.", 4],
          forkthree: ["\\left\\{ \\begin{array}{l l} #1 & \\mbox{#2}\\\\ #3 & \\mbox{#4}\\\\ #5 & \\mbox{#6}\\\\ \\end{array} \\right.", 6],
          forkfour: ["\\left\\{ \\begin{array}{l l} #1 & \\mbox{#2}\\\\ #3 & \\mbox{#4}\\\\ #5 & \\mbox{#6}\\\\ #7 & \\mbox{#8}\\\\ \\end{array} \\right.", 8],
          vecthree: ["\\begin{bmatrix} #1\\\\ #2\\\\ #3 \\end{bmatrix}", 3],
          vecthreethree: ["\\begin{bmatrix} #1 & #2 & #3\\\\ #4 & #5 & #6\\\\ #7 & #8 & #9 \\end{bmatrix}", 9],
          cameramatrix: ["#1 = \\begin{bmatrix} f_x & 0 & c_x\\\\ 0 & f_y & c_y\\\\ 0 & 0 & 1 \\end{bmatrix}", 1],
          distcoeffs: ["(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6 [, s_1, s_2, s_3, s_4[, \\tau_x, \\tau_y]]]]) \\text{ of 4, 5, 8, 12 or 14 elements}"],
          distcoeffsfisheye: ["(k_1, k_2, k_3, k_4)"],
          hdotsfor: ["\\dots", 1],
          mathbbm: ["\\mathbb{#1}", 1],
          bordermatrix: ["\\matrix{#1}", 1]
      }
  }
}
);
//]]>
</script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js" type="text/javascript"></script>
<link href="../../doxygen.css" rel="stylesheet" type="text/css"/>
<link href="../../stylesheet.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<!--#include virtual="/google-search.html"-->
<table cellpadding="0" cellspacing="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="../../opencv-logo-small.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">OpenCV
    <span id="projectnumber">4.5.2</span>
   </div>
   <div id="projectbrief">Open Source Computer Vision</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "../../search",false,'Search');
</script>
<script src="../../menudata.js" type="text/javascript"></script>
<script src="../../menu.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
  initMenu('../../',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow" onkeydown="return searchBox.OnSearchSelectKey(event)" onmouseout="return searchBox.OnSearchSelectHide()" onmouseover="return searchBox.OnSearchSelectShow()">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe frameborder="0" id="MSearchResults" name="MSearchResults" src="javascript:void(0)">
</iframe>
</div>
<div class="header">
  <div class="summary">
<a href="#nested-classes">Classes</a> |
<a href="#enum-members">Enumerations</a> |
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">Optimization Algorithms<div class="ingroups"><a class="el" href="../../d0/de1/group__core.html">Core functionality</a></div></div>  </div>
</div><!--header-->
<div class="contents">
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a>
Classes</h2></td></tr>
<tr class="memitem:"><td align="right" class="memItemLeft" valign="top">class  </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d0/d21/classcv_1_1ConjGradSolver.html">cv::ConjGradSolver</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft"> </td><td class="mdescRight">This class is used to perform the non-linear non-constrained minimization of a function with known gradient,.  <a href="../../d0/d21/classcv_1_1ConjGradSolver.html#details">More...</a><br/></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:"><td align="right" class="memItemLeft" valign="top">class  </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d4/d43/classcv_1_1DownhillSolver.html">cv::DownhillSolver</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft"> </td><td class="mdescRight">This class is used to perform the non-linear non-constrained minimization of a function,.  <a href="../../d4/d43/classcv_1_1DownhillSolver.html#details">More...</a><br/></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:"><td align="right" class="memItemLeft" valign="top">class  </td><td class="memItemRight" valign="bottom"><a class="el" href="../../df/d11/classcv_1_1MinProblemSolver.html">cv::MinProblemSolver</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft"> </td><td class="mdescRight">Basic interface for all solvers.  <a href="../../df/d11/classcv_1_1MinProblemSolver.html#details">More...</a><br/></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="enum-members"></a>
Enumerations</h2></td></tr>
<tr class="memitem:ga86a370deffb37af51deb405a634eb14c"><td align="right" class="memItemLeft" valign="top">enum  </td><td class="memItemRight" valign="bottom"><a class="el" href="../../da/d01/group__core__optim.html#ga86a370deffb37af51deb405a634eb14c">cv::SolveLPResult</a> { <br/>
  <a class="el" href="../../da/d01/group__core__optim.html#gga86a370deffb37af51deb405a634eb14ca53443e5084b8afbd368920564a005e6b">cv::SOLVELP_UNBOUNDED</a> = -2, 
<br/>
  <a class="el" href="../../da/d01/group__core__optim.html#gga86a370deffb37af51deb405a634eb14cae1450427844e557ad644cb4fcd44edef">cv::SOLVELP_UNFEASIBLE</a> = -1, 
<br/>
  <a class="el" href="../../da/d01/group__core__optim.html#gga86a370deffb37af51deb405a634eb14ca4f5a045a7b15b7b64acee6107b76e7b5">cv::SOLVELP_SINGLE</a> = 0, 
<br/>
  <a class="el" href="../../da/d01/group__core__optim.html#gga86a370deffb37af51deb405a634eb14ca94f9f0f66b795a4df9861e236064f1f0">cv::SOLVELP_MULTI</a> = 1
<br/>
 }<tr class="memdesc:ga86a370deffb37af51deb405a634eb14c"><td class="mdescLeft"> </td><td class="mdescRight">return codes for <a class="el" href="da/d01/group__core__optim.html#ga9a06d237a9d38ace891efa1ca1b5d00a" title="Solve given (non-integer) linear programming problem using the Simplex Algorithm (Simplex Method)...">cv::solveLP()</a> function  <a href="../../da/d01/group__core__optim.html#ga86a370deffb37af51deb405a634eb14c">More...</a><br/></td></tr>
</td></tr>
<tr class="separator:ga86a370deffb37af51deb405a634eb14c"><td class="memSeparator" colspan="2"> </td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga9a06d237a9d38ace891efa1ca1b5d00a"><td align="right" class="memItemLeft" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="../../da/d01/group__core__optim.html#ga9a06d237a9d38ace891efa1ca1b5d00a">cv::solveLP</a> (<a class="el" href="../../dc/d84/group__core__basic.html#ga353a9de602fe76c709e12074a6f362ba">InputArray</a> Func, <a class="el" href="../../dc/d84/group__core__basic.html#ga353a9de602fe76c709e12074a6f362ba">InputArray</a> Constr, <a class="el" href="../../dc/d84/group__core__basic.html#gaad17fda1d0f0d1ee069aebb1df2913c0">OutputArray</a> z)</td></tr>
<tr class="memdesc:ga9a06d237a9d38ace891efa1ca1b5d00a"><td class="mdescLeft"> </td><td class="mdescRight">Solve given (non-integer) linear programming problem using the Simplex <a class="el" href="../../d3/d46/classcv_1_1Algorithm.html" title="This is a base class for all more or less complex algorithms in OpenCV. ">Algorithm</a> (Simplex Method).  <a href="../../da/d01/group__core__optim.html#ga9a06d237a9d38ace891efa1ca1b5d00a">More...</a><br/></td></tr>
<tr class="separator:ga9a06d237a9d38ace891efa1ca1b5d00a"><td class="memSeparator" colspan="2"> </td></tr>
</table>
<a id="details" name="details"></a><h2 class="groupheader">Detailed Description</h2>
<p>The algorithms in this section minimize or maximize function value within specified constraints or without any constraints. </p>
<h2 class="groupheader">Enumeration Type Documentation</h2>
<a id="ga86a370deffb37af51deb405a634eb14c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga86a370deffb37af51deb405a634eb14c">◆ </a></span>SolveLPResult</h2>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">enum <a class="el" href="../../da/d01/group__core__optim.html#ga86a370deffb37af51deb405a634eb14c">cv::SolveLPResult</a></td>
        </tr>
      </table>
</div><div class="memdoc">
<p><code>#include &lt;<a class="el" href="../../d3/d46/optim_8hpp.html">opencv2/core/optim.hpp</a>&gt;</code></p>
<p>return codes for <a class="el" href="../../da/d01/group__core__optim.html#ga9a06d237a9d38ace891efa1ca1b5d00a" title="Solve given (non-integer) linear programming problem using the Simplex Algorithm (Simplex Method)...">cv::solveLP()</a> function </p>
<table class="fieldtable">
<tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><a id="gga86a370deffb37af51deb405a634eb14ca53443e5084b8afbd368920564a005e6b"></a>SOLVELP_UNBOUNDED <div class="python_language">Python: cv.SOLVELP_UNBOUNDED</div></td><td class="fielddoc"><p>problem is unbounded (target function can achieve arbitrary high values) </p>
</td></tr>
<tr><td class="fieldname"><a id="gga86a370deffb37af51deb405a634eb14cae1450427844e557ad644cb4fcd44edef"></a>SOLVELP_UNFEASIBLE <div class="python_language">Python: cv.SOLVELP_UNFEASIBLE</div></td><td class="fielddoc"><p>problem is unfeasible (there are no points that satisfy all the constraints imposed) </p>
</td></tr>
<tr><td class="fieldname"><a id="gga86a370deffb37af51deb405a634eb14ca4f5a045a7b15b7b64acee6107b76e7b5"></a>SOLVELP_SINGLE <div class="python_language">Python: cv.SOLVELP_SINGLE</div></td><td class="fielddoc"><p>there is only one maximum for target function </p>
</td></tr>
<tr><td class="fieldname"><a id="gga86a370deffb37af51deb405a634eb14ca94f9f0f66b795a4df9861e236064f1f0"></a>SOLVELP_MULTI <div class="python_language">Python: cv.SOLVELP_MULTI</div></td><td class="fielddoc"><p>there are multiple maxima for target function - the arbitrary one is returned </p>
</td></tr>
</table>
</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a id="ga9a06d237a9d38ace891efa1ca1b5d00a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga9a06d237a9d38ace891efa1ca1b5d00a">◆ </a></span>solveLP()</h2>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int cv::solveLP </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="../../dc/d84/group__core__basic.html#ga353a9de602fe76c709e12074a6f362ba">InputArray</a> </td>
          <td class="paramname"><em>Func</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="../../dc/d84/group__core__basic.html#ga353a9de602fe76c709e12074a6f362ba">InputArray</a> </td>
          <td class="paramname"><em>Constr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="../../dc/d84/group__core__basic.html#gaad17fda1d0f0d1ee069aebb1df2913c0">OutputArray</a> </td>
          <td class="paramname"><em>z</em> </td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table><table class="python_language"><tr><th colspan="999" style="text-align:left">Python:</th></tr><tr><td style="width: 20px;"></td><td>retval, z</td><td>=</td><td>cv.solveLP(</td><td class="paramname">Func, Constr[, z]</td><td>)</td></tr></table>
</div><div class="memdoc">
<p><code>#include &lt;<a class="el" href="../../d3/d46/optim_8hpp.html">opencv2/core/optim.hpp</a>&gt;</code></p>
<p>Solve given (non-integer) linear programming problem using the Simplex <a class="el" href="../../d3/d46/classcv_1_1Algorithm.html" title="This is a base class for all more or less complex algorithms in OpenCV. ">Algorithm</a> (Simplex Method). </p>
<p>What we mean here by "linear programming problem" (or LP problem, for short) can be formulated as:</p>
<p class="formulaDsp">
\[\mbox{Maximize } c\cdot x\\ \mbox{Subject to:}\\ Ax\leq b\\ x\geq 0\]
</p>
<p>Where \(c\) is fixed <code>1</code>-by-<code>n</code> row-vector, \(A\) is fixed <code>m</code>-by-<code>n</code> matrix, \(b\) is fixed <code>m</code>-by-<code>1</code> column vector and \(x\) is an arbitrary <code>n</code>-by-<code>1</code> column vector, which satisfies the constraints.</p>
<p>Simplex algorithm is one of many algorithms that are designed to handle this sort of problems efficiently. Although it is not optimal in theoretical sense (there exist algorithms that can solve any problem written as above in polynomial time, while simplex method degenerates to exponential time for some special cases), it is well-studied, easy to implement and is shown to work well for real-life purposes.</p>
<p>The particular implementation is taken almost verbatim from <b>Introduction to Algorithms, third edition</b> by T. H. Cormen, C. E. Leiserson, R. L. Rivest and Clifford Stein. In particular, the Bland's rule <a href="http://en.wikipedia.org/wiki/Bland%27s_rule">http://en.wikipedia.org/wiki/Bland%27s_rule</a> is used to prevent cycling.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">Func</td><td>This row-vector corresponds to \(c\) in the LP problem formulation (see above). It should contain 32- or 64-bit floating point numbers. As a convenience, column-vector may be also submitted, in the latter case it is understood to correspond to \(c^T\). </td></tr>
    <tr><td class="paramname">Constr</td><td><code>m</code>-by-<code>n+1</code> matrix, whose rightmost column corresponds to \(b\) in formulation above and the remaining to \(A\). It should contain 32- or 64-bit floating point numbers. </td></tr>
    <tr><td class="paramname">z</td><td>The solution will be returned here as a column-vector - it corresponds to \(c\) in the formulation above. It will contain 64-bit floating point numbers. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>One of <a class="el" href="../../da/d01/group__core__optim.html#ga86a370deffb37af51deb405a634eb14c" title="return codes for cv::solveLP() function ">cv::SolveLPResult</a> </dd></dl>
</div>
</div>
</div><!-- contents -->
<!-- HTML footer for doxygen 1.8.6-->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Fri Apr 2 2021 11:36:40 for OpenCV by  <a href="http://www.doxygen.org/index.html">
<img alt="doxygen" class="footer" src="../../doxygen.png"/>
</a> 1.8.13
</small></address>
<script type="text/javascript">
//<![CDATA[
addTutorialsButtons();
//]]>
</script>
</body>
</html>
